package com.hanlink.dsp.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * Copyright (C), 深圳市东乘电子科技有限公司
 * Carate By YangZhong
 */
public class RotationFrameLayout extends FrameLayout {
    private float mRotation;
    public RotationFrameLayout(@NonNull Context context) {
        super(context);
        init();
    }

    public RotationFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public RotationFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }
    protected void init(){
        setRotation(-90);
//        setPivotX(0f);
//        setPivotY(0f);
    }


    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        Log.d("TT", "onSizeChanged:"+ w +" " + h +" " + getPivotX() +" " + getPivotY()+" " + getTag());
        float x = getPivotX();
        float y = getPivotY();//514   565
        setPivotY(x);
        setPivotX(x );
//        setPivotY((w-h)/2f);
    }



    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        Log.d("TT", "onLayout:"+ left +" " + top +" "+ right +" " + bottom);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
        Log.d("TT", "onMeasure:"+ getTag() );
    }
}
